import Vue from 'vue'
import Router from 'vue-router'
import routes from './routers'
import store from '@/store'
Vue.use(Router)

const router = new Router({
  routes,
  base: JX_ENV.publicPath == '/' ? `/` : `/${JX_ENV.publicPath}/`,
  mode: 'hash'
})

router.beforeEach((to, from, next) => {
  store.dispatch('setMenuIndex', {
    pIndex: to.meta.pIndex,
    mIndex: to.meta.mIndex,
    pName: to.meta.pName,
  })
  store.dispatch('setBreak', to.meta)
  next()
})

export default router